package com.watchme.es.service;


import java.io.*;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;


public class PropertiesHelper {

    public static Map<String, String> mapCache = new HashMap<>();
    private String path;

    public PropertiesHelper(String path) {
        this.path = path;
    }


    /**
     * 根据Key 和 properties 名称，获取对应properties文件的值
     *
     * @return
     * @throws IOException
     */
    public Properties getKeyValue() {
        Properties properties = new Properties();
        InputStream inputStream = null;
        InputStreamReader inputStreamReader = null;
        try {
            inputStream = new FileInputStream(new File(path));
            inputStreamReader = new InputStreamReader(inputStream, "utf-8");
            properties.load(inputStreamReader);
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                if (null != inputStream) {
                    inputStream.close();
                }
                if (null != inputStreamReader) {
                    inputStreamReader.close();
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return properties;

    }


}
